# import numpy as np
# import matplotlib.pyplot as plt
# from mpl_toolkits.mplot3d import Axes3D
#
# # 创建 3D 图形
# fig = plt.figure()
# ax = fig.add_subplot(111, projection='3d')
#
# # 定义网格数据
# x = np.linspace(1, 10, 100)
# y = np.linspace(1, 10, 100)
# X, Y = np.meshgrid(x, y)
#
# # 生成三个不同的曲面来表示三个 Pareto 前沿
# Z1 = 15 - (X + Y)  # 第一个前沿
# Z2 = 20 - (X + Y)  # 第二个前沿
# Z3 = 25 - (X + Y)  # 第三个前沿
#
# # 绘制曲面
# ax.plot_surface(X, Y, Z1, color='b', alpha=0.3, rstride=100, cstride=100)
# ax.plot_surface(X, Y, Z2, color='g', alpha=0.3, rstride=100, cstride=100)
# ax.plot_surface(X, Y, Z3, color='r', alpha=0.3, rstride=100, cstride=100)
#
# # 标注示例点
# points = {
#     "A": (3, 4, 8),
#     "B": (5, 5, 5),
#     "C": (7, 6, 3),
# }
#
# # 绘制并标注点
# for label, (px, py, pz) in points.items():
#     ax.scatter(px, py, pz, color='black', s=50)
#     ax.text(px, py, pz, f'{label} ({px}, {py}, {pz})', color='black', fontsize=10)
#
# # 设置轴标签
# ax.set_xlabel('Objective 1')
# ax.set_ylabel('Objective 2')
# ax.set_zlabel('Objective 3')
#
# plt.title('3D Pareto Fronts')
# plt.show()


import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D

# 创建 3D 图形
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')

# 定义网格数据
x = np.linspace(-5, 5, 100)
y = np.linspace(-5, 5, 100)
X, Y = np.meshgrid(x, y)

# 使用二次函数生成三个不同的曲面，表示三个 Pareto 前沿，并增加间距
Z1 = 0.5 * (X**2) + 0.5 * (Y**2) + 10  # 第一个前沿
Z2 = 0.5 * (X**2) + 0.5 * (Y**2) + 30  # 第二个前沿
Z3 = 0.5 * (X**2) + 0.5 * (Y**2) + 50  # 第三个前沿

# 绘制曲面，设置不同的透明度和颜色来区分每个前沿
ax.plot_surface(X, Y, Z1, color='b', alpha=0.6, edgecolor='none')
ax.plot_surface(X, Y, Z2, color='g', alpha=0.6, edgecolor='none')
ax.plot_surface(X, Y, Z3, color='r', alpha=0.6, edgecolor='none')

# 标注示例点
points = {
    "A": (1, 1, 11),
    "B": (2, 2, 14),
    "C": (3, 3, 19),
}

# 绘制并标注点
for label, (px, py, pz) in points.items():
    ax.scatter(px, py, pz, color='black', s=50)
    ax.text(px, py, pz, f'{label} ({px}, {py}, {pz})', color='black', fontsize=10)

# 设置轴标签
ax.set_xlabel('Objective 1')
ax.set_ylabel('Objective 2')
ax.set_zlabel('Objective 3')

# 设置标题
plt.title('3D Pareto Fronts with Quadratic Surfaces')
plt.show()
